package Lesson19.NotePad;

class Page 
{
	private String title;
	private String text ="";
	
	Page(String newTitle)
	{
		if(newTitle == null)
		{
			System.out.println("Wrong title format!");
			this.title = "";
		}
		else
		{
			this.title = newTitle;
		}
	}
	void addText(final String newText)
	{
		if(newText != null)
			this.text += newText;
		else
			System.out.println("Wrong text format!");
	}
	void deleteText()
	{
		this.text = "";
	}
	String reviewPage()
	{
		return this.title + "\n" + this.text;
	}
	
	@Override
	public boolean equals(Object obj)
	{
		if(obj!= null && obj instanceof Page)
		{
			return ((Page) obj).title.equals(this.title);
		}
		else
			return false;
	}
	
}
